<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>3-5 计算属性的 getter 和 setter</title>
    <script src="../vue.js"></script>
</head>

<body>
    <div id="app">
        {{fullName}}
    </div>

    <script>
        var vm = new Vue({
            el: '#app',
            data: {
                first: 'yu',
                last: 'kai'
            },
            computed: {
                fullName: {
                    get() {
                        return this.first + " " + this.last;
                    },
                    set(value) {
                        console.log("value: " + value);
                        var arr = value.split("");
                        this.first = arr[0];
                        this.last = arr[1];
                    }
                }
            }
            // computed: {
            //     fullName() {
            //         return this.first + " " + this.last;
            //     }
            // }
        })
    </script>
</body>

</html>